<template>
    <div class="hello">
      微信登录
    </div>
</template>


<script>
import Vue from 'vue'
import {setCookie,getCookie,delCookie} from '@/api/cookie.js'
Vue.prototype.$cookieStore = {setCookie,getCookie,delCookie}
export default {
  data() {
    return {

    };
  },
  created:function () {

    this.$emit('footer', false);
      var that = this
      var code       = this.$route.query.code;
      console.log(code);
      if(code){
        var target_url = that.$cookieStore.getCookie('target_url');
        console.log(target_url);
        var params     = {'code':code};
        this.$api.get('/Wechat/wechat',params).then(res => {
            console.log(res);
            //setCookie( 'userid' , res.user.id,36000);
            // console.log(that.$cookieStore.getCookie('userid'));
            setCookie( 'target_url' ,  '');

             window.location.replace(target_url);
        })

      }else{
         // alert(2);
        // window.location.replace(target_url);
        console.log('错误');
      }
  },
  methods: {

  },
};
</script>

<style scoped>
</style>
